package com.gxc.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * @author GongXincheng
 * @since 2019-10-12 22:28
 */
@RestController
public class UploadController {

    @PostMapping("/file")
    public String upload(@RequestParam("file") MultipartFile file) throws IOException {
        System.out.println("Name：" + file.getName());
        System.out.println("OriginalFilename：" + file.getOriginalFilename());
        System.out.println("ContentType：" + file.getContentType());
        System.out.println("Size：" + file.getSize());

        System.out.println(new String(file.getBytes(), StandardCharsets.UTF_8));
        return "success";
    }


}
